<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Vue demo07(指令)</title>
    <script src="../build/vue.js"></script>
</head>
<body>
<div id="app">
    <input type="text" v-on:keyup.enter="changeMessage" v-model="newMessage">
    <p v-if="greeting">{{message | capitalize}}</p>
</div>
<script>
    var vm = new Vue({
        el: '#app',
        data: {
            greeting: true,
            message: 'hello!',
            newMessage: ''
        },
        methods: {
            changeMessage: function () {
                var msg = this.newMessage.trim();

                if(msg) {
                    this.message = msg;
                }
            }
        }
    });
</script>
</body>
</html>